/*
 * @Descripttion: 
 * @version: 
 * @Author: sueRimn
 * @Date: 2022-09-28 11:28:10
 * @LastEditors: sueRimn
 * @LastEditTime: 2022-11-29 10:54:03
 */
/*
 * @Descripttion: 
 * @version: 
 * @Author: sueRimn
 * @Date: 2022-09-28 11:28:10
 * @LastEditors: sueRimn
 * @LastEditTime: 2022-09-30 16:07:13
 */

let db = require("../db/index");
let { query } = require("../db/pool")
exports.auth = (req, res) => {
  let params = req.body;
  let strSql = "select * from user where login_name='" + params.userName + "' && password='" + params.password + "'";
  // db.query(strSql, (err, data) => {
  //   if (err) {
  //     res.send({
  //       status: 0,
  //       message: "failed",
  //       data: {}
  //     })
  //   };
  //   if (data instanceof Array && data.length == 1) {
  //     res.send({
  //       status: 1,
  //       message: "ok",
  //       data: data[0]
  //     })
  //   } else {
  //     res.send({
  //       status: 0,
  //       message: "failed",
  //       data: {}
  //     })
  //   }
  // })
  userQuery(strSql, res)
}
exports.logout = (req, res) => {
  res.send({
    status: 1,
    message: "ok",
    data: {}
  })
}

async function userQuery(sql, res) {
  let rtn = await query(sql);
  res.send(rtn);
}
